<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}Django博客系统{% endblock %}</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        /* 添加前面提供的CSS样式 */
    </style>
    {% block extra_css %}{% endblock %}
</head>
<body>
    <!-- 导航栏 -->
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark sticky-top">
        <div class="container">
            <a class="navbar-brand" href="{% url 'blog:home' %}">
                <i class="fas fa-blog me-2"></i>Django博客
            </a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav me-auto">
                    <li class="nav-item"><a class="nav-link" href="{% url 'blog:home' %}">首页</a></li>
                    <li class="nav-item"><a class="nav-link" href="{% url 'blog:about' %}">关于</a></li>
                    {% if user.is_authenticated %}
                    <li class="nav-item"><a class="nav-link" href="{% url 'blog:post_create' %}">写文章</a></li>
                    {% endif %}
                </ul>
                <div class="d-flex">
                    {% if user.is_authenticated %}
                    <div class="dropdown">
                        <button class="btn btn-outline-light dropdown-toggle" type="button" id="userMenu" data-bs-toggle="dropdown">
                            <i class="fas fa-user-circle me-1"></i>{{ user.username }}
                        </button>
                        <ul class="dropdown-menu dropdown-menu-end">
                            <li><a class="dropdown-item" href="{% url 'users:profile' %}">个人资料</a></li>
                            <li><a class="dropdown-item" href="{% url 'blog:post_create' %}">写文章</a></li>
                            <li><hr class="dropdown-divider"></li>
                            <li><a class="dropdown-item" href="{% url 'users:logout' %}">退出</a></li>
                        </ul>
                    </div>
                    {% else %}
                    <a href="{% url 'users:login' %}" class="btn btn-outline-light me-2">登录</a>
                    <a href="{% url 'users:register' %}" class="btn btn-primary">注册</a>
                    {% endif %}
                </div>
            </div>
        </div>
    </nav>

    <!-- 消息通知 -->
    <div class="container mt-3">
        {% if messages %}
            {% for message in messages %}
            <div class="alert alert-{{ message.tags }} alert-dismissible fade show" role="alert">
                {{ message }}
                <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
            </div>
            {% endfor %}
        {% endif %}
    </div>

    <!-- 主要内容区 -->
    {% block content %}{% endblock %}

    <!-- 页脚 -->
    <footer class="footer mt-5">
        <div class="container">
            <div class="row">
                <div class="col-md-4 mb-4">
                    <h5 class="text-white mb-4"><i class="fas fa-blog me-2"></i>Django博客</h5>
                    <p>一个基于Python Django框架构建的个人博客平台，分享技术文章、编程经验和生活随笔。</p>
                </div>
                <div class="col-md-2 mb-4">
                    <h5 class="text-white mb-4">快速链接</h5>
                    <ul class="list-unstyled">
                        <li class="mb-2"><a href="{% url 'blog:home' %}">首页</a></li>
                        <li class="mb-2"><a href="{% url 'blog:about' %}">关于我们</a></li>
                    </ul>
                </div>
                <div class="col-md-3 mb-4">
                    <h5 class="text-white mb-4">分类目录</h5>
                    <ul class="list-unstyled">
                        {% for category in categories|slice:":5" %}
                        <li class="mb-2">
                            <a href="{% url 'blog:category_posts' category.slug %}">
                                {{ category.name }}
                            </a>
                        </li>
                        {% endfor %}
                    </ul>
                </div>
            </div>
            <hr class="my-4 bg-light">
            <div class="text-center">
                <p class="mb-0">© {% now "Y" %} Django博客系统 | 基于Python Django框架构建</p>
            </div>
        </div>
    </footer>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    <script>
        // 简单的交互效果
        document.querySelectorAll('.post-card').forEach(card => {
            card.addEventListener('mouseenter', () => {
                card.style.transform = 'translateY(-5px)';
            });

            card.addEventListener('mouseleave', () => {
                card.style.transform = 'translateY(0)';
            });
        });
    </script>
    {% block extra_js %}{% endblock %}
</body>
</html>